﻿using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;

namespace CrazyTasksWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += (s, e) =>
                {
                    DispatcherTimer timer = new DispatcherTimer();
                    timer.Interval = new TimeSpan(0, 0, 3);
                    timer.Tick += (s1, e1) =>
                        {
                            UpdateTasks();
                        };
                    timer.Start();
                };
        }

        private void UpdateTasks()
        {
            var processes = Process.GetProcesses();
            TaskList.ItemsSource = processes;
        }
    }
}
